package HashCcollision;

import java.util.HashSet;
import java.util.Set;

/**
 * @author chaird
 * @create 2022-07-31 22:08
 */
public class App {

  public static void main(String[] args) {

    Set<Integer> set = new HashSet<>();
    int hashcode = 0;

    // 10w
    int size = 11 * 10000;
    System.out.println("init :" + size);
    for (int i = 0; i < size; i++) {
      hashcode = new Object().hashCode();
      if (set.contains(hashcode)) {
        System.out.println("第" + i + "次出现了 哈希冲突");
      } else {
        set.add(hashcode);
      }
    }
      System.out.println("finish :" + set.size());
  }
}
